<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
     <ul>
        <!-- <li v-for="(item, index) in userList" :key="index">
         id:{{item.id}}---姓名:{{item.name}}---性别:{{item.gender==1?"男":"女"}}
        </li> -->
        <li v-for="(item, index) in userList" :key="index">
            id:{{item.id}}---姓名:{{item.name}}---性别:{{item.gender | filtergender}}
        </li>
     </ul>
    </div>
</body>

<script src="./node_modules/vue/dist/vue.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            userList:[
                {id:1,name:'猪猪侠',gender:1},
                {id:2,name:'猪猪侠2',gender:1},
                {id:3,name:'猪猪侠3',gender:0}
            ]
        },
        methods: {
            formatgender(gender){
              if(gender==1){
                return "男"
              }else{
                return "女"
              }
            }
        },
        //过滤器，专门针对数据过滤的
        filters:{
            filtergender(gender){
              if(gender==1){
                return "男"
              }else{
                return "女"
              }
            }
        }
    })
</script>
</html>